cmake_minimum_required(VERSION 3.14)

project(WingCoroutine LANGUAGES CXX)

set(CMAKE_CXX_STANDARD 20)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

if(WIN32)
  add_definitions(-DOS_WINDOWS)
  if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
    message(FATAL_ERROR "Compiling on Windows MSVC is not supported!")
  elseif(CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
    if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
      message(NOTICE "Compiling with MinGW x64...")
    else()
      message(FATAL_ERROR "Compiling with MinGW x32 is not supported!")
    endif()
  else()
    message(FATAL_ERROR "Unknown compiler!!!")
  endif()
elseif(UNIX AND NOT APPLE)
  add_definitions(-DOS_LINUX)
  if("${CMAKE_SIZEOF_VOID_P}" STREQUAL "8")
    message(NOTICE "Compiling with gcc x64...")
  else()
    message(FATAL_ERROR "Compiling with gcc x32 is not supported!")
  endif()
else()
  message(FATAL_ERROR "Unsupported operating system!")
endif()

add_library(
  WingCoroutine SHARED WingCoroutine_global.h wingcoroutine.cpp wingcoroutine.h
                       wingcoroutine_p.h wingcoroutine_p.cpp)

target_compile_definitions(WingCoroutine PRIVATE WINGCOROUTINE_LIBRARY)
